﻿using SlamDunk.ValueObjects.Enums;
using System;

namespace SlamDunk.MES.DataDrive.Bussiness.Models.ResourceContext
{
    /// <summary>
    /// 物料类
    /// </summary>
    public class MaterialClass
    {
        public string 物料类编号 { get; set; }
        public string 物料类名称 { get; set; }
        public string 工厂模型编号 { get; set; }
        public string 物料来源类型 { get; set; }
        public string 描述 { get; set; }
        public string 上级节点编号 { get; set; }
        internal MaterialSourceType MaterialSourceType { get; set; }
        /// <summary>
        /// 导入数据时代码赋值
        /// </summary>
        internal Guid? 上级节点Id { get; set; }

        public void ConverterValue()
        {
            if (!string.IsNullOrWhiteSpace(this.物料来源类型))
            {
                this.MaterialSourceType = (MaterialSourceType)Enum.Parse(typeof(MaterialSourceType), this.物料来源类型.Substring(0, this.物料来源类型.IndexOf("(", StringComparison.Ordinal)));
            }
        }
    }
}
